import sys
sys.path.append('gen-py')

from hello import Hello
from hello.ttypes import *
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer

class HelloHandler:
	def sayHello(self, name):
		return 'Hello {}'.format(name)
	def pdf(self):
		return open('spring-framework-reference.pdf').read()

if __name__ == '__main__':
	handler = HelloHandler()
	processor = Hello.Processor(handler)
	transport = TSocket.TServerSocket(port=9000)
	tfactory = TTransport.TBufferedTransportFactory()
	pfactory = TBinaryProtocol.TBinaryProtocolFactory()

	server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)
	print 'Starting server ...'
	server.serve()
	print 'Done ...'
